import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import space from '@/components/space'
import login from '@/components/login'
import channel from '@/components/channel'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      component: index
    },
    {
      path: '/channel/:tid',
      name: 'channel',
      component: channel
    },
    {
      path: '/space/',
      name: 'space',
      component: space,
      meta:{
      	requireAuth:true
      }
    },
    {
      path: '/login',
      name: 'login',
      component: login
    },
  ]
})
//全局守卫
//router.beforeEach((to,from,next)=>{
//	if(to.matched.some(record=>record.meta.requireAuth)){
//		if(localStorage.getItem("isLogin")){
//			next()
//		}else{
//			next({
//				path:'/login',
//				query:{
//					redirect:to.fullPath
//				}
//			})
//		}
//	}
//	else{
//		next()
//	}
//	console.log(to)
//	console.log(from)	
//	next()
//})

export default router